package Controller;

import java.util.ArrayList;
import java.util.List;

import Beans.TicketBean;
import DTO.TicketDTO;
import Model.Ticket;

public class AdministradorTicket {
private static AdministradorTicket instancia;
	
	public AdministradorTicket(){
		
	}
	public static AdministradorTicket getInstancia() {
		if(instancia==null)
			instancia=new AdministradorTicket();
		return instancia;
	}
	public TicketBean fromModelTOBean(Ticket ticket) {
		TicketBean ticketb=null;
		if(ticket!=null){
			ticketb=new TicketBean();
			ticketb.setEmpresa(ticket.getEmpresa());
			ticketb.setIdTicket(ticket.getId());
			ticketb.setTipoTarjeta(ticket.getTipoTarjeta());
			ticketb.setValor(ticket.getValor());
		}
		return ticketb;
	}
	public Ticket fromBeanTOModel(TicketBean ticketb) {
		Ticket ticket=null;
		if(ticketb!=null){
			ticket=new Ticket();
			ticket.setEmpresa(ticketb.getEmpresa());
			ticket.setId(ticketb.getIdTicket());
			ticket.setTipoTarjeta(ticketb.getTipoTarjeta());
			ticket.setValor(ticketb.getValor());
		}
		return ticket;
	}
	
	public Ticket fromDTOTOModel(TicketDTO ticketb) {
		Ticket ticket=null;
		if(ticketb!=null){
			ticket=new Ticket();
			ticket.setEmpresa(ticketb.getEmpresa());
			ticket.setId(ticketb.getId());
			ticket.setTipoTarjeta(ticketb.getTipoTarjeta());
			ticket.setValor(ticketb.getValor());
		}
		return ticket;
	}
	
	public TicketDTO fromModelTODTO(Ticket ticket) {
		TicketDTO ticketDTO=null;
		if(ticket!=null){
			ticketDTO=new TicketDTO();
			ticketDTO.setEmpresa(ticket.getEmpresa());
			ticketDTO.setId(ticket.getId());
			ticketDTO.setTipoTarjeta(ticket.getTipoTarjeta());
			ticketDTO.setValor(ticket.getValor());
		}
		return ticketDTO;
	}
	public List<Ticket> fromBeanTOModel(List<TicketBean> ticketsTotal) {
		List<Ticket> tickets=new ArrayList<Ticket>();
		for (TicketBean ticketb : ticketsTotal) {
			Ticket ticket=fromBeanTOModel(ticketb);
			tickets.add(ticket);
		}
		return tickets;
	}
	public List<TicketDTO> fromModelTODTO(List<Ticket> ticketsTotal) {
		List<TicketDTO> ticketsDTO=new ArrayList<TicketDTO>();
		for (Ticket ticket : ticketsTotal) {
			TicketDTO ticketDTO=fromModelTODTO(ticket);
			ticketsDTO.add(ticketDTO);
		}
		return ticketsDTO;
	}
	public List<Ticket> fromDTOTOModel(List<TicketDTO> ticketsTotal) {
		List<Ticket> tickets=new ArrayList<Ticket>();
		for (TicketDTO ticketDTO : ticketsTotal) {
			Ticket ticket=fromDTOTOModel(ticketDTO);
			tickets.add(ticket);
		}
		return tickets;
	}
	public List<TicketBean> fromModelTOBean(List<Ticket> ticketsTotal) {
		List<TicketBean> ticketsBean=new ArrayList<TicketBean>();
		for (Ticket ticket : ticketsTotal) {
			TicketBean ticketb=fromModelTOBean(ticket);
			ticketsBean.add(ticketb);
		}
		return ticketsBean;
	}
}
